/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q0104.java
 * @Author : WangRuoyu
 * @Date 2022/12/27 17:04
 */

package leetcode;

import util.TreeNode;

public class Q0104 {

    public int maxDepth(TreeNode root) {
        if (root == null) return 0;
        return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }

    public static void main(String[] args) {
        Q0104 sl = new Q0104();
        TreeNode root = new TreeNode(1, new TreeNode(2, new TreeNode(4), null), new TreeNode(3));
        System.out.println(sl.maxDepth(root));
    }
}
